const {
    Mysql
} = require('../tools/utils');
module.exports = async (ctx) => {
    let {
        sharerId,
        receiverId
    } = ctx.query;
    if (sharerId == 'undefined' || receiverId == 'undefined') {
        ctx.state.data = {
            code: '002'
        }
    } else {
        let sql = `SELECT * from cSessionInfo WHERE uid=${receiverId}`;
        let sql3 = `INSERT INTO intergal(uid,score) VALUES(${sharerId},3) ON DUPLICATE KEY UPDATE uid=${sharerId},score=score+3`;
        try {
            let res = await Mysql(sql);
            if (!res.length) {
                let sql2 = `INSERT INTO shareList(sharer_uid,receriver_uid,intergal) VALUES(${sharerId},${receiverId},3)`
                await Mysql(sql2);
                await Mysql(sql3);
            }
        } catch (error) {
            ctx.state.data = {
                code: '002'
            }
        }
    }
}